import { Column, Table } from '@zxhhyj/storm'
import { Playlist, playlistTable } from './Playlist'
import { Song, songTable } from './Song'

interface PlaylistSong {
  playlist: Playlist
  song: Song
  createDateTime: Date
}

class PlaylistSongTable extends Table<PlaylistSong> {
  override readonly tableName: string = 't_playlist_song'
  readonly id = Column.references('playlist_id', playlistTable).primaryKey(true).bindTo(this, 'playlist')
  readonly song = Column.references('song_id', songTable).notNull().bindTo(this, 'song')
  readonly createDateTime = Column.timestamp('create_datetime').notNull().bindTo(this, 'createDateTime')
}

export const playlistSongTable = new PlaylistSongTable()